Repository navigation
Conversation
Preserve the case-insensitive duplicate-field fallback and the whole-value Variant reader guards.
sunchao
left a comment
There was a problem hiding this comment.
Summary
- Prior state and problem: Spark’s whole-value Variant scan rewrite caused native scans to fall back, including under Spark 4.1’s default configuration.
- Design approach: Recognize exactly one
RequestedVariantField.fullVariant, carry its identity through protobuf and Arrow metadata, and reuse the existing Variant normalizer. - Correctness / compatibility analysis: Request metadata matches Spark sources across 4.0.0, 4.0.4, 4.1.0, 4.1.3 and 4.2.0. Null handling and Spark’s wrapper layout agree. Typed, nested and multi-field requests retain fallback. No introduced P1/P2 issues found within this review.
- Key design decisions: The dedicated request flag keeps serialization narrow. The wrapper shares normalized buffers and validity data without another full-column copy. Existing FFI ownership and row-conversion paths remain applicable.
- Implementation sketch: Scan admission validates the request, serde preserves its identity, the schema adapter normalizes and wraps the column, and JVM import restores metadata for Spark’s projection.
- Behavioral changes worth calling out: Compared with
branch-1.1, whole-value rewritten scans intentionally become native, and shredded objects containing empty keys gain a reconstruction fix. The existing normalizer’s cost now also applies to rewritten scans. No performance benchmark was run. - Suggested improvements: No P1/P2 code changes to request.
Reviewed all 18 changed files at e02715d6d868f4da4707f077bc048e2ad5dbbf66 against base fef94f6cd78b18151dff57b7a936798385356de5. GitHub confirms non-draft status. The snapshot and live discussion endpoints contain no existing review concerns. Routed skills: review-comet-pr, review-comet-expression-pr, and review-comet-ffi-pr.
Exact-head CI: run 37207859295 passed native tests, including all three new Rust regression tests, and Spark 4.1 scans, including the new whole-value and fallback assertions. Shuffle, TPC-H, native build and profile compilation checks also passed. Expressions, execution and TPC-DS remain running. No failed checks were reported.
Validation limits: Spark SQL jobs were skipped, and nondefault Spark profile runtime tests were not run. The local native attempt failed because HDFS compilation could not find jni.h. A subsequent build without HDFS reached its 180-second limit before executing tests. No local JVM tests completed. Broader compatibility validation remains outstanding.
Which issue does this PR close?
Closes #5519.
Rationale for this change
#5868 already supports native
SELECT v FROM tscans withspark.sql.variant.pushVariantIntoScan=false. Spark 4.1 enables this rewrite by default, requestingstruct<0: variant>instead of a plain Variant column, which previously forced Comet to fall back. This PR accepts that whole-value request and reuses the existing Variant reader.What changes are included in this PR?
Recognize Spark's single full-Variant request, reuse the native normalizer, and preserve the wrapper's metadata and nulls through serialization and FFI. Update the Variant support documentation.
How are these changes tested?
Native Parquet and Comet Variant tests cover canonical and shredded values, nulls, metadata, unsupported requests, and reader guards. Selected upstream Spark 4.1.3 assertions also pass with the native rewrite enabled.
The broader native run has a timing-sensitive failure in the unchanged S3 credential refresh test, which passes in isolation.
Draft pending broader Spark CI: please apply
run-spark-4.1-testsandrun-all-spark-profilesbefore marking ready for review.